﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Template/Site_Main.Master"
    CodeBehind="student_manage.aspx.cs" Inherits="RegisterationSystem.Space_Education.student_manage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">
      <!--
        $(function () {
            //设置导航位置
            setLocalToParent();
            //初始化隐藏层
            $('#plastudentinfo').dialog({
                closed: true
            });
            //初始化企业用户数据列表控件
            $("#dg").datagrid({
                idField: "id",      //标识字段,主键
                url: "../SyncService/GetDataList.ashx?action=getallstudentmanagelist",
                queryParams: { "where": "1=1" },
                pagination: true,   //是否开启分页
                rownumbers: true,   //行号
                pageSize: 10,
                pageNumber: 1,
                columns: [[
                             { field: 'ck', checkbox: true },
                            { field: 'truename', title: '学生姓名', width: 105, align: 'center' },
                            { field: 'sex', title: '性别', width: 60, align: 'center', formatter: function (value, row) {
                                if (value) {
                                    return "女";
                                } else {
                                    return "男";
                                }
                            }
                            },
                            { field: 'idcardnumber', title: '证件号(身份证/护照)', width: 125, align: 'center' },
                            { field: 'houseareaid', title: '户口所在地', width: 143.5, align: 'center', formatter: function (value, row) {
                                switch (value) {
                                    case "0":
                                        return "武汉经济技术开发区（汉南区）";
                                        break;
                                    case "1":
                                        return "市内其它区";
                                        break;
                                    case "2":
                                        return "省内市外、外省外市";
                                        break;
                                    case "3":
                                        return "外籍(含港澳台)";
                                        break;
                                }
                            }
                        },
                            { field: 'pianname', title: '住房片区', width: 125, align: 'center' },
                            { field: 'scommname', title: '住房社区', width: 125, align: 'center' },
                            { field: 'xcommname', title: '住房小区', width: 125, align: 'center' },
                            { field: 'level', title: '生源类型', width: 60, align: 'center', formatter: function (value, row) {
                                switch (value) {
                                    case "0":
                                        return "A";
                                        break;
                                    case "1":
                                        return "B";
                                        break;
                                    case "2":
                                        return "C";
                                        break;
                                    case "3":
                                        return "D";
                                        break;
                                }
                            }
                            },
                            { field: 'preschoolsid', title: '幼儿园', width: 130, align: 'center', formatter: function (value, row) {
                                    switch (value) {
                                        case "0":
                                            return "未选择幼儿园";
                                            break;
                                        case "1":
                                            return "纱帽山幼儿园";
                                            break;
                                        case "2":
                                            return "育才幼儿园";
                                            break;
                                        case "3":
                                            return "顺意幼儿园";
                                            break;
                                        case "4":
                                            return "武汉碧桂园幼儿园";
                                            break;
                                        case "5":
                                            return "御景华府快乐天使幼儿园";
                                            break;
                                        case "6":
                                            return "南国江城未来星幼儿园";
                                            break;
                                        case "7":
                                            return "薇湖水岸双语幼儿园";
                                            break;
                                        case "8":
                                            return "晓晓幼儿园";
                                            break;
                                        case "9":
                                            return "蔷薇幼儿园";
                                            break;
                                        case "10":
                                            return "小聪聪幼儿园";
                                            break;
                                        case "11":
                                            return "小星星幼儿园";
                                            break;
                                        case "12":
                                            return "甫兰幼儿园";
                                            break;
                                        case "13":
                                            return "育苗幼儿园";
                                            break;
                                        case "14":
                                            return "农科所幼儿园";
                                            break;
                                        case "15":
                                            return "汉武国际城幼儿园";
                                            break;
                                        case "16":
                                            return "银莲湖小学幼儿园";
                                            break;
                                        case "17":
                                            return "汉南小学幼儿园";
                                            break;
                                        case "18":
                                            return "博才幼儿园";
                                            break;
                                        case "19":
                                            return "水洪幼儿园";
                                            break;
                                        case "20":
                                            return "邓南中心小学幼儿园";
                                            break;
                                        case "21":
                                            return "健康幼儿园";
                                            break;
                                        case "22":
                                            return "大嘴小学幼儿园";
                                            break;
                                        case "23":
                                            return "江下小学幼儿园";
                                            break;
                                        case "24":
                                            return "乌金学校幼儿园";
                                            break;
                                        case "25":
                                            return "东荆幼儿园";
                                            break;
                                        case "26":
                                            return "无证园";
                                            break;
                                        case "27":
                                            return "区外幼儿园";
                                            break;
                                        case "28":
                                            return "圣特立小太阳幼儿园";
                                            break;
                                    }    
                                }
                            },
                            { field: 'id', title: '查看详细信息', width: 125, align: 'center', formatter: function (value, row) {
                                return "<a href='javascript:void(0)'  onclick='GetByStudentInfo(" + value + ");'>查看详细信息</a>";
                            }
                            }
                         ]],
                onClickRow: function (index, row) {
                    if (editIndex != index) {
                        if (endEditing()) {
                            $('#dg').datagrid('beginEdit', index);
                            editIndex = index;
                        } else {
                            $('#dg').datagrid('selectRow', editIndex);
                        }
                    }
                }
            })
        });
        //-->
        //查询
        function SelDistributedStuList() {
            var where = "";
            where += $("#txtname").val() + ","; //学生姓名
            where += $("#txtcard").val() + ""; //身份证
            $('#dg').datagrid({ url: "../SyncService/GetDataList.ashx?action=getallstudentmanagelist", queryParams: { "where": where} });
            $('#dg').datagrid('reload');
        }
        var editIndex = undefined;
        function endEditing() {
            if (editIndex == undefined) { return true }
            if ($('#dg').datagrid('validateRow', editIndex)) {
                var ed = $('#dg').datagrid('getEditor', { index: editIndex, field: 'id' });
                //var productname = $(ed.target).combobox('getText');
                //$('#tt').datagrid('getRows')[editIndex]['productname'] = productname;
                $('#dg').datagrid('endEdit', editIndex);
                editIndex = undefined;
                return true;
            } else {
                return false;
            }
        }
        //删除学生
        function DelStus() {
            //修改未编辑完的行
            $('#dg').datagrid('endEdit', editIndex);
            //id集合
            var ids = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            //是否选中行
            if (rows.length == 0) {
                alert("请选择行");
                return;
            }
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                ids += rows[i].id + ",";
            }
            //alert(ids);
            $.messager.confirm('提示', '确认删除？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "del", "id": ids }, function (data) {
                        $.messager.alert("消息提示", "删除成功！");
                        $('#dg').datagrid('reload');
                    });
                }
            });
        }

        //弹出学生详细信息
        function GetByStudentInfo(stdID) {
            $.post("../SyncService/GetDataList.ashx",
                { "action": "GetStudentByID", "id": stdID },
                function (cStr) {
                    var stdInfo = eval('(' + cStr + ')');
                    $("#<%= hidstuID.ClientID %>").val(stdID);
                    $("#spanname").text(stdInfo.name); //姓名
                    $("#spansex").text(stdInfo.sex); //性别
                    $("#spanbirthday").text(stdInfo.birthday); //出生年月
                    $("#spanidcardnumber").text(stdInfo.idcardnumber); //学生身份证
                    $("#HouseIngoingTime").text(stdInfo.HouseIngoingTime); //户口迁入时间
                    $("#HousingOccupancyTime").text(stdInfo.HousingOccupancyTime); //住房入住时间
                    $("#PermanentAddress").text(stdInfo.PermanentAddress); //户籍地址
                    // $("#spanhobby").text(stdInfo.hobby);//兴趣爱好
                    $("#spanfirstguardianname").text(stdInfo.firstguardianname); //第一监护人
                    $("#spanfirstguardianunit").text(stdInfo.firstguardianunit); //工作单位
                    $("#spanfirstguardianphone").text(stdInfo.firstguardianphone); //联系电话
                    $("#spansecguardianname").text(stdInfo.secguardianname); //第二监护人
                    $("#spansecguardianunit").text(stdInfo.secguardianunit); //工作单位
                    $("#spansecguardianphone").text(stdInfo.secguardianphone); //联系电话
                    switch (stdInfo.houseareaid) {
                        case "0":
                            $("#spanhouseareaid").text("武汉经济技术开发区（汉南区）"); //户口所在地
                            break;
                        case "1":
                            $("#spanhouseareaid").text("市内其它区"); //户口所在地
                            break;
                        case "2":
                            $("#spanhouseareaid").text("省内市外、外省外市"); //户口所在地
                            break;
                        case "3":
                            $("#spanhouseareaid").text("外籍(含港澳台)"); //户口所在地
                            break;
                    }
                    $("#spanpcommname").text(stdInfo.pcommname); //住房社区
                    $("#spanscommname").text(stdInfo.scommname); //住房社区
                    $("#spanxcommname").text(stdInfo.xcommname); //住房小区
                    $("#spanhousenumber").text(stdInfo.housenumber); //门牌号
                    $("#spanhousecard").text(stdInfo.housecard); //房产号
                    $("#spanfirstrelationship").text(stdInfo.firstrelationship); //与学生关系
                    $("#spansecrelationship").text(stdInfo.secrelationship); //与学生关系
                },
                "text");
            //弹层
            $('#plastudentinfo').dialog({
                title: '学生信息',
                width: 600,
                height: 425,
                closed: false,
                cache: false,
                modal: true,
                collapsible: true,
                maximizable: false
            });
        }
        //重置学生用户密码
        function UpdStudentPswdReset(StudentPswd) {
            $.messager.confirm('提示', '确认重置密码？', function (r) {
                if (r) {
                    $.post(location.href, { "action": "pswdreset", "id": $("#<%= hidstuID.ClientID %>").val(), "StudentPswd": StudentPswd }, function (data) {
                        $.messager.alert("消息提示", "重置成功！");
                        $('#plastudentinfo').dialog("close");
                        $('#dg').datagrid('reload');
                    });
                }
            });
        }


        //把符合条件选定的数据导出excel
        function derive_excel() {
            var mess = "";
            var altmess = "";
            mess = "确认导出excel？";
            altmess = "导出excel成功!"
            //id集合
            var ids = "";
            //获取选择集合
            var rows = $('#dg').datagrid('getSelections');
            if (rows.length == 0) {
                alert("请选择行");
                return false;
            }
            //遍历选择行
            for (var i = 0; i < rows.length; i++) {
                ids += rows[i].id + ",";
            }

            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/EduExcelHelper.ashx?type=derive_excelList&id=" + ids,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                }
            });
        }

        //把符合条件的所以数据导出excel
        function derive_excelAll() {
            var mess = "";
            mess = "确认导出excel？";
            var where = "";
            where += $("#txtname").val() + ","; //学生姓名
            where += $("#txtcard").val() + ","; //身份证
            where += "";
            $.messager.confirm('提示', mess, function (r) {
                if (r) {
                    $.ajax({
                        type: "POST",
                        url: "../SyncService/EduExcelHelper.ashx?type=derive_excelManageList&where=" + where,
                        //                data: { "type": "loadReport", "typeid": "0", "where": "" + where + "" },
                        datatype: "text",
                        cache: false,
                        success: function (data) {
                            if (data == "0") {
                                alert("导出excel失败");
                            }
                            else {
                                try {
                                    window.location = data;
                                } catch (e) {

                                }
                            }
                        }
                    });
                }
            });
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Place_Local" runat="server">
    <div class="localTitle">
        <a>学生信息管理</a>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!--选择的学生信息编号-->
    <asp:HiddenField ID="hidstuID" runat="server" />
    <div class="loadheight">
        <table width="100%%" border="0" cellspacing="0" cellpadding="0">
            <tr>
                <td bgcolor="#FFFFFF">
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                                </table>
                            </td>
                        </tr>
                    </table>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>学生信息检索条件</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table width="100%" border="0" cellpadding="0" cellspacing="1">
                                    <tr>
                                        <td height="20">
                                            <table width="100%%" border="0" cellspacing="0" cellpadding="3">
                                            </table>
                                            <div style="margin-top: 5px">
                                            </div>
                                            <table width="688" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
                                                <tr>
                                                    <td width="100" height="20" align="center" bgcolor="#FFFFFF">
                                                        学生姓名
                                                    </td>
                                                    <td width="200" bgcolor="#FFFFFF">
                                                        <input type="text" id="txtname" style="width: 160px;" class="easyui-validatebox" />
                                                    </td>
                                                    <td width="120" align="center" bgcolor="#FFFFFF">
                                                        证件号(身份证/护照)
                                                    </td>
                                                    <td align="left" bgcolor="#FFFFFF">
                                                        <input type="text" id="txtcard" style="width: 160px;" class="easyui-validatebox" />
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <div style="margin-top: 5px">
                    </div>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td width="200">
                                &nbsp;
                            </td>
                            <td>
                                <input type="button" name="button" id="button" value="查询" class="anniu" width="73"
                                    height="27" onclick="SelDistributedStuList();" />
                            </td>
                        </tr>
                    </table>
                    <div style="height: 5px;">
                    </div>
                    <table width="100%%" border="0" cellspacing="0" cellpadding="1">
                        <tr>
                            <td class="cen_R_dh">
                                <strong>学生信息列表</strong>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <!-- 创建数据列表控件 -->
                                <table id="dg">
                                </table>
                                <div style="height: 10px;">
                                </div>
                                <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                    <tr>
                                        <td align="left">
                                            <input type="button" name="button2" id="button1" value="删除" class="anniu" width="73"
                                                height="27" onclick="DelStus();" />
                                            <input type="button" name="button1" id="button3" value="选定导出Excel" class="anniu_big"
                                                width="73px" height="23px" onclick="derive_excel();" />
                                            <input type="button" name="button1" id="button4" value="全部导出Excel" class="anniu_big"
                                                height="23px" onclick="derive_excelAll();" />
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                    <!--弹出学生详细信息-->
                    <div id="plastudentinfo" class="easyui-dialog tcc_M">
                        <div class="tcc_div" style="margin-left: 20px;">
                            <ul>
                                <li class="tcc_BT">学生详细信息</li>
                                <li>姓名：<span id="spanname"></span></li>
                                <li>性别：<span id="spansex"></span></li>
                                <li>证件号(身份证/护照)：<span id="spanidcardnumber"></span>&nbsp;<a href='javascript:void(0)'
                                    onclick='UpdStudentPswdReset(123456);' style="color: #990000">密码重置</a></li>
                                <li>出生年月：<span id="spanbirthday"></span></li>
                                <li>户口所在地：<span id="spanhouseareaid"></span></li>
                                <li>住房片区：<span id="spanpcommname"></span></li>
                                <li>住房社区：<span id="spanscommname"></span></li>
                                <li>住房小区：<span id="spanxcommname"></span></li>
                                <li>门牌号：<span id="spanhousenumber"></span></li>
                                <li>房产证号：<span id="spanhousecard"></span></li>
                                <li>户口迁入时间：<span id="HouseIngoingTime"></span></li>
                                <li>住房入住时间：<span id="HousingOccupancyTime"></span></li>
                                <li>户籍地址：<span id="PermanentAddress"></span></li>
                                <%--<li>兴趣爱好：<span id="spanhobby"></span></li>--%>
                            </ul>
                        </div>
                        <div class="tcc_div" style="float: right">
                            <ul>
                                <li class="tcc_BT">监护人信息</li>
                                <li>第一监护人：<span id="spanfirstguardianname"></span></li>
                                <li>与学生关系：<span id="spanfirstrelationship"></span></li>
                                <li>工作单位：<span id="spanfirstguardianunit"></span></li>
                                <li>联系电话：<span id="spanfirstguardianphone"></span></li>
                                <li>&nbsp;</li>
                                <li>第二监护人：<span id="spansecguardianname"></span></li>
                                <li>与学生关系：<span id="spansecrelationship"></span></li>
                                <li>工作单位：<span id="spansecguardianunit"></span></li>
                                <li>联系电话：<span id="spansecguardianphone"></span></li>
                            </ul>
                        </div>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
